package com.uidt.project.ptsj.controller;

import com.uidt.framework.aspectj.lang.annotation.Anonymous;
import com.uidt.framework.web.controller.BaseController;
import com.uidt.framework.web.domain.AjaxResult;
import com.uidt.framework.web.page.TableDataInfo;
import com.uidt.project.ptsj.domain.*;
import com.uidt.project.ptsj.mapper.OfficerMapper;
import com.uidt.project.ptsj.mapper.RankMapper;
import com.uidt.project.ptsj.obj.ScreenSeachObj;
import com.uidt.project.ptsj.service.IDataSyncService;
import com.uidt.project.ptsj.service.IScreenService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Anonymous
@RestController
@RequestMapping("/screen")
public class DashboardControler extends BaseController {
    @Autowired
    OfficerMapper officerMapper;

    @Autowired
    IDataSyncService dataSyncService;

    @Autowired
    IScreenService screenService;

    @Autowired
    RankMapper rankMapper;

    /**
     * 红黑榜
     */
    @Anonymous
    @GetMapping("/listRank")
    public TableDataInfo listRank(Rank rank) {
        startPage();
        List<Rank> list = rankMapper.selectRankList(rank);
        return getDataTable(list);
    }

    /**查询最高最低分
     *
     */
    @Anonymous
    @GetMapping("/getScoreRank")
    public AjaxResult getScoreRank(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getScoreRank(screenSeachObj));
    }

    /**
     * 查询积分排名清单
     * @return
     */
    @Anonymous
    @GetMapping("/getScoreList")
    public TableDataInfo getScoreList(ScreenSeachObj screenSeachObj) {
        startPage();
        List<CountItem> list = screenService.getScoreList(screenSeachObj);
        return getDataTable(list);
    }

    /**
     *三色排名
     */
    @Anonymous
    @GetMapping("/getColorCount")
    public AjaxResult getColorCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getColorCount(screenSeachObj));
    }

    /**
     * 经营状态
     */
    @Anonymous
    @GetMapping("/getStatusCount")
    public TableDataInfo getStatusCount() {
        return getDataTable(screenService.getStatusCount());
    }

    /**
     * 星级统计
     */
    @Anonymous
    @GetMapping("/getStarsCount")
    public AjaxResult getStarsCount(ScreenSeachObj screenSeachObj) {
        List<Map<String,String>> list = screenService.getStarsCount(screenSeachObj);
        return AjaxResult.success(list);
    }

    /**
     * 客源分析
     */
    @Anonymous
    @GetMapping("/listGuestCount")
    public AjaxResult listGuestCount() {
        return AjaxResult.success(screenService.listGuestCount());
    }

    /**
     * 亮相台 负责人列表
     * @return
     */
    @Anonymous
    @GetMapping("/officer")
    public TableDataInfo officer(ScreenSeachObj screenSeachObj) {
        startPage();
        String gxdwdm = screenSeachObj.getGxdwdm();
        if(gxdwdm.equals("330999080000") || gxdwdm.equals("330999620000")){
            gxdwdm = gxdwdm.substring(0,8);
        }else {
            gxdwdm = gxdwdm.substring(0,6);
        }
        List<Officer> list = officerMapper.getLXT(gxdwdm);
        return getDataTable(list);
    }

    /**
     * 事件列表 eventInfo.status=0 已办 除此以外是待办
     * * @return
     */
    @Anonymous
    @GetMapping("/listevent")
    public TableDataInfo listevent(ScreenSeachObj screenSeachObj) {
        startPage();
        List<EventInfo> list = screenService.listEvent(screenSeachObj);
        return getDataTable(list);
    }

    /**
     * 部门事件处理统计（各单位工作情况）
     * @return
     */
    @Anonymous
    @GetMapping("/getEventDepartmentCount")
    public AjaxResult getEventDepartmentCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getEventDepartmentCount(screenSeachObj));
    }

    /**
    事件来源统计
     */
    @Anonymous
    @GetMapping("/getEventSourceCount")
    public AjaxResult getEventSourceCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getEventSourceCount(screenSeachObj));
    }

    /**
     * 检查台数据统计
     * @return
     */
    @Anonymous
    @GetMapping("/getInspectionCount")
    public AjaxResult getInspectionCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getInspectionCount(screenSeachObj));
    }

    /**
     * 部门巡检统计,共治单位，巡检数
     * @return
     */
    @Anonymous
    @GetMapping("/getInspectionDepartmentCount")
    public AjaxResult getInspectionDepartmentCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getInspectionDepartmentCount(screenSeachObj));
    }

    /**
    近一个月巡检记录
     */
    @Anonymous
    @GetMapping("/listLastInspection")
    public TableDataInfo listLastInspection(ScreenSeachObj screenSeachObj) {
        startPage();
        List<Inspection> list = screenService.listLastInspection(screenSeachObj);
        return getDataTable(list);
    }

    /**
     * 场所总数、房源总数、入住统计
     * @return
     */
    @Anonymous
    @GetMapping("/getRoomCount")
    public AjaxResult getRoomCount(ScreenSeachObj screenSeachObj) {
        return AjaxResult.success(screenService.getRoomCount(screenSeachObj));
    }

    /**
     * 警示信息
     */
    @Anonymous
    @GetMapping("/getWarning")
    public TableDataInfo getWarning() {
        return getDataTable(screenService.getWarning());
    }

    /**
     * 数据同步
     * @return
     */
    @Anonymous
    @GetMapping("/sync")
    public String SyncData(){
        dataSyncService.syncRoomInfo();
        return "success";
    }


    /**
     * 全市大屏中间头部，各区县数据接口
     * @return
     */
    @Anonymous
    @GetMapping("/qsBigscreenCenterData")
    public AjaxResult qsBigscreenCenterData(){

        return screenService.qsBigscreenCenterData();
    }

    /**
     * 各个区县大屏中间头部，各小区数据接口
     * @return
     */
    @Anonymous
    @GetMapping("/qxBigscreenCenterData")
    public AjaxResult qxBigscreenCenterData(ScreenSeachObj screenSeachObj){

        return screenService.qxBigscreenCenterData(screenSeachObj);
    }


}
